package com.jd.jobkeeper.client;

import com.jd.jobkeeper.protocals.Response;
import com.jd.jobkeeper.protocals.Task;
import com.jd.jobkeeper.transport.Transport;
import reactor.core.publisher.Mono;

public interface JobClientProtocol {


    /**
     * Listen transport build
     * @param t
     */
    void onConnected(Transport t);

    /**
     * Accept task and run it
     * @param task
     * @param transport
     * @return
     */
    Mono<Void> run(Task task, Transport transport);

    /**
     * Kill the task
     * @param task
     */
    Mono<Response> kill(Task task);

    /**
     * Interrupt current running task
     */
    void interrupt();

    /**
     * Check the task is running
     *
     * @param task
     * @return
     */
    Mono<Response> isRunning(Task task);

    /**
     * Register a task handler
     * @param handler
     */
    void register(Handler handler);

    /*  Mono<Node> changeLeader(Node node);*/

    /**
     * Stop
     */
    void stop();
}
